package com.py.androidUtils.UI;

import java.util.ArrayList;
import java.util.List;

import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import com.py.androidUtils.UI.adapter.ArticleDetailsAdapter;
import com.py.androidUtils.UI.adapter.ArticleDetailsAdapter.ArticleDetailsClik;
import com.py.androidUtils.UI.view.emoji.FaceConversionUtil;
import com.py.androidUtils.UI.view.emoji.FaceRelativeLayout;
import com.py.androidUtils.base.BaseListActivity;
import com.py.androidUtils.pulltorefrsh.PullToRefreshBase.Mode;
import com.readyidu.app.R;

public class MessageActivity extends BaseListActivity<Object> {
	private RelativeLayout facechoose;
	private FaceRelativeLayout layout;
	private EditText edMessage;
	private ImageView showEmojii;

	@Override
	public void onActivityCreatedCallBack() {
		getTitleActionBar().setTitleBar("详情");
		getTitleActionBar().setImgLeft(R.drawable.icon_back, new OnClickListener() {
			@Override
			public void onClick(View v) {
				finishactivity(MessageActivity.this);
			}
		});
		commAdapter = new ArticleDetailsAdapter(MessageActivity.this);

		showEmojii.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				if (facechoose.getVisibility() == View.VISIBLE) {
					facechoose.setVisibility(View.GONE);
				} else {
					facechoose.setVisibility(View.VISIBLE);
				}
			}
		});

		((ArticleDetailsAdapter) commAdapter).setArticleDetailsClik(new ArticleDetailsClik() {
			@Override
			public void comments(String name) {
				edMessage.setText("");
				edMessage.setHint(name);
			}

			@Override
			public void chckUser(Object object) {

			}
		});
	}

	@Override
	public void doInbackgroundCallBack() {
		List<Object> list = new ArrayList<Object>();
		for (int i = 0; i < 30; i++) {
			list.add(new Object());
		}
		baseAction.update(list);
	}

	@Override
	public void onPreExecuteCallBack() {
		// TODO Auto-generated method stub

	}

	@Override
	public List<Object> doHandelData(Object object) {
		List<Object> list = (List<Object>) object;
		return list;
	}

	@Override
	public void onItemClickCallBack(AdapterView<?> parent, View view, int position, long id) {
	}

	@Override
	public View getHeadView() {
		return null;
	}

	@Override
	public View getFooterView() {
		FaceConversionUtil.getInstace().getFileText(getApplication());
		View view = LayoutInflater.from(MessageActivity.this).inflate(R.layout.common_emoji_view, null);
		facechoose = (RelativeLayout) view.findViewById(R.id.ll_facechoose);
		layout = (FaceRelativeLayout) view.findViewById(R.id.FaceRelativeLayout);
		edMessage = (EditText) view.findViewById(R.id.edMessage);
		showEmojii = (ImageView) view.findViewById(R.id.showEmojii);
		layout.setEditText(edMessage);
		return view;
	}

	@Override
	public Mode getListViewMode() {
		return BOTH;
	}

}
